package edu.yourl.admin.web;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.spring.injection.annot.SpringBean;

import edu.yourl.admin.presenter.IAdminUserPresenter;
import edu.yourl.domain.Gossip;

public class AdminGossipPage extends WebPage {

	@SpringBean
	private IAdminUserPresenter presenter;

	public AdminGossipPage() {
		add(new ListView<Gossip>("listview",presenter.getGossips()) {
			
			private static final long serialVersionUID = 1L;

			@Override
			protected void populateItem(ListItem<Gossip> item) {
				Gossip gossip = item.getModelObject();
				item.add(new Label("reported",gossip.isAbuse() ? ("by " + gossip.getAbuseReport().getReporter().toString() + " on " + gossip.getAbuseReport().getWhen().toString()) : ""));
				item.add(new Label("message",gossip.getMessage()));
				item.add(new Label("date",gossip.getDate().toString()));
				item.add(new Label("to",gossip.getTo() != null ? gossip.getTo().toString() : "--"));
			}
		});
	}
	
	
	public void setPresenter(IAdminUserPresenter presenter) {
		this.presenter = presenter;
	}
}
